﻿/*
 ***************************************************************************
 * Microsoft Visual C# .NET
 * 名称：       App_Input_EmployInterviewPrintForm
 * 类型：       控制层
 * 功能说明：   录取通知打印页面
 * 作者：       徐傲明
 * 创建日期：   2008/02/22
 * 修改日期     修改者      修改内容
 * 
 * 
 * ---
 ***************************************************************************
*/

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shpm.App.Master.Bean;
using Shpm.App.Master.Dao;
using System.Globalization;
using Shpm.App.Commons.Utils;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
using System.Text.RegularExpressions;
using Shpm.App.Input.Dao;
using Shpm.App.Input.Bean;
using Shpm.App.Commons.Db.Beans.Master;

public partial class App_Input_EmployInterviewPrintForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //接受数据
        string interviewId = Convert.ToString(Request.QueryString["INTERVIEW_ID"]);

        //打印
        set1(interviewId); 

    }

    /*名称： set1
    *功能： 数据打印
    *参数： string interviewId
    *返回： 无
    *说明： 无
    */
    private void set1(string interviewId)
    {
        MemoryStream stream = new MemoryStream();


        Document document = new Document(PageSize.A4, 80, 50, 30, 65);



        PdfWriter pdfWriter = PdfWriter.GetInstance(document, stream);
        document.Open();


        FontFactory.RegisterDirectory("c:\\Windows\\Fonts");

        FontSelector selector = new FontSelector();

        Font font = FontFactory.GetFont("simsun", BaseFont.IDENTITY_H, 14, Font.BOLD, new Color(0, 0, 0));

        selector.AddFont(font);
        string strWord;

        //显示标题
        Paragraph title = new Paragraph(selector.Process("新 员 录 用 通 知 书"));
        //Paragraph title1 = new Paragraph(selector.Process(memberNo));

        title.Alignment = Element.ALIGN_CENTER;

        document.Add(title);

        EmployInterviewBean bean = new EmployInterviewBean();
        EmployInterviewDao dao = new EmployInterviewDao();
        bean.InterviewId =Convert.ToInt32(interviewId);
        bean = dao.GetInterInfo(bean);


        //显示打印数据
        PdfPTable table = new PdfPTable(1);
        PdfPCell cell = new PdfPCell(new Paragraph(" "));

        //显示录取者基本资料
        cell.Border = 0;
        table.AddCell(cell);

        font.Size = 10;
        cell.HorizontalAlignment = Element.ALIGN_LEFT;
        if (bean.InterviewSex == "01")
        {
            cell.Phrase = selector.Process("尊敬的" + bean.InterviewName + "先生 ： 您好！");
        }
        else if (bean.InterviewSex == "02")
        {
            cell.Phrase = selector.Process("尊敬的" + bean.InterviewName + "女士 ： 您好！");
        }
        else
        {
            cell.Phrase = selector.Process("尊敬的" + bean.InterviewName + "先生/女士 ： 您好！");
        }
        table.AddCell(cell);

        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);
        //数据输出
        font = FontFactory.GetFont("simsun", BaseFont.IDENTITY_H, 10, Font.UNDEFINED, new Color(0, 0, 0));
        selector = new FontSelector();
        selector.AddFont(font);
        cell.HorizontalAlignment = Element.ALIGN_LEFT;
        cell.Border = 0;
        strWord = "    首先，诚挚欢迎您加入亲和源股份有限公司！";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);

        strWord = "    鉴于我们双方在面试过程中的了解，我们认为您基本符合我司招聘岗位要求，拟聘用您担任部门";
        font = FontFactory.GetFont("simsun", BaseFont.IDENTITY_H, 10, Font.UNDERLINE, new Color(0, 0, 0));
        FontSelector selectorJobName = new FontSelector();
        selectorJobName.AddFont(font);
        cell.Phrase.Add(selector.Process(strWord));
        //cell.Phrase = selectorJobName.Process(bean.JobName);
        cell.Phrase.Add(selectorJobName.Process(bean.JobName));
        cell.Phrase.Add(selector.Process("一职。"));
        //jobCell = cell;

        table.AddCell(cell);
        table.DeleteRow(5);
        cell.Phrase = selector.Process("");

        strWord = "    您进入本公司报到时将与我司签订为期_______年的_____________合同;其中包含_____个月的试用期；自确认入职日期起确定合同生效之日。相关手续将依据《上海市劳动合同条例》的有关规定及公司有关规章制度办理。您将享受的待遇为：";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        strWord = "    1.月薪金：________元 /月 ，试用期间按_____％(包括个人解缴四金、个人所得税)。";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        strWord = "    2.公司规定的其他有关福利。";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        strWord = "    有关薪酬福利、工作时间、合同的续签、变更、解除、终止等内容将会在与您签订的合同中列明。";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        strWord = "    本通知书发出之日起_____天内该职位有效，逾期将不为您保留该职位。";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);
        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);
        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);
        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);
        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);
        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);
        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);
        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);
        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);

        font = FontFactory.GetFont("simsun", BaseFont.IDENTITY_H, 10, Font.UNDEFINED, new Color(0, 0, 0));
        selector = new FontSelector();
        selector.AddFont(font);
        strWord = "    请您确认准备如下事项:";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);


        font = FontFactory.GetFont("simsun", BaseFont.IDENTITY_H, 10, Font.UNDEFINED,  new Color(0, 0, 0));
        selector = new FontSelector();
        selector.AddFont(font);
        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);

        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);

        strWord = "    1.确认报到日期：　　　年　　月　　日";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        strWord = "    2.请准备证件资料：学校推荐表、身份证原件、学历证书原件、相关证书证件原件、退休/下岗/协保证明、退工单和劳动手册、公积金帐号、照片（1寸2张）、体检报告（报到时带来）。";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);


        strWord = "    联系人：              电话：		";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);
        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);


        strWord = "    	在此，谨代表公司全体员工衷心祝愿您在新的工作岗位上积极努力，与公司共创美好未来！";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);


        cell.HorizontalAlignment = Element.ALIGN_LEFT;
        strWord = "                                                            行政人事部";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.HorizontalAlignment = Element.ALIGN_LEFT;
        strWord = "                                                            亲和源";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        strWord = Convert.ToString(DateTime.Now.Year) + "年" + Convert.ToString(DateTime.Now.Month) + "月" + Convert.ToString(DateTime.Now.Day) +"日";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.HorizontalAlignment = Element.ALIGN_LEFT;
        strWord = "    本通知书仅仅作为拟聘的通知形式";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);


        //strWord = "_________________________________________________________________________";
        strWord = "-------------------------------------------------------------------------";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);


        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);


        font = FontFactory.GetFont("simsun", BaseFont.IDENTITY_H, 10, Font.BOLD, new Color(0, 0, 0));
        selector = new FontSelector();
        selector.AddFont(font);
        cell.HorizontalAlignment = Element.ALIGN_CENTER;
        cell.Border = 0;
        cell.Phrase = selector.Process("确  认  回  执");
        table.AddCell(cell);

        cell.Border = 0;
        cell.Phrase = selector.Process("");
        table.AddCell(cell);

        font = FontFactory.GetFont("simsun", BaseFont.IDENTITY_H, 10, Font.UNDEFINED, new Color(0, 0, 0));
        selector = new FontSelector();
        selector.AddFont(font);
        cell.HorizontalAlignment = Element.ALIGN_LEFT;
        cell.Border = 0;
        cell.Phrase = selector.Process("    我已清楚并确认以上信息，我将于       年   月   日来公司报到，并带齐以上相关材料。若材料与事实不符，则愿意承担责任。");
        table.AddCell(cell);

        
        strWord = "                                                          签名:";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);

        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        strWord = " 年   月   日";
        cell.Phrase = selector.Process(strWord);
        table.AddCell(cell);


        document.Add(table);
        document.Close();
        Response.AddHeader("Cache-Control", "cache");
        Response.AddHeader("Content-Type", "application/pdf");
        Response.AddHeader("Content-Length", stream.GetBuffer().Length.ToString());
        // Response.AddHeader("Content-Disposition", "attachment;filename=shpm.pdf");
        Response.BinaryWrite(stream.GetBuffer());

        Response.End();
    }
}
